package com.project.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author RJ
 * @date 2022/10/13 16:36
 */
@RestController
@RequestMapping("login")
public class LoginController {
    @PostMapping("loginUser")
    public boolean loginUser(String userName, String userPwd) {
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken token = new UsernamePasswordToken(userName, userPwd);
        try {
            subject.login(token);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}
